import init.samsungexynos8890.usb.rc
import init.baseband.rc
import init.rilcommon.rc
import init.wifi.rc
import init.samsung.rc
import init.rilcommon.rc
# import init.power.rc

on early-init
    mount debugfs /sys/kernel/debug /sys/kernel/debug

on init
    start watchdogd
    mkdir /preload 0771 system system

    # See storage config details at http://source.android.com/tech/storage/
    mkdir /mnt/shell/emulated 0700 shell shell
    mkdir /storage/emulated 0555 root root

    # Support legacy paths
    symlink /sdcard /mnt/sdcard
    symlink /sdcard /storage/sdcard0
    symlink /sdcard1 /storage/sdcard1
    symlink /sdcard1 /mnt/extSdCard
    symlink /sdcard1 /mnt/sdcard1
    symlink /sdcard1 /external_sd
    symlink /storage/usbdisk /mnt/usbdisk

    export EXTERNAL_STORAGE /sdcard

    #export SECONDARY_STORAGE /storage/extSdCard

    symlink /data/app /factory
	#Reactivation Lock
    symlink /dev/block/platform/155a0000.ufs/by-name/STEADY /dev/block/steady

	#Google FRP solution
    symlink /dev/block/platform/155a0000.ufs/by-name/PERSISTENT /dev/block/persistent

on post-fs-data
    mkdir /data/media 0770 media_rw media_rw

    setprop vold.post_fs_data_done 1

# sem_daemon permission
    chown system system /efs/sec_efs/ssp_data
    chmod 0644 /efs/sec_efs/ssp_data

# Permissions for audio
    chown system radio /sys/class/audio/earjack/select_jack
    chown system radio /sys/class/audio/earjack/key_state
    chown system radio /sys/class/audio/earjack/state
    chown system radio /sys/class/audio/earjack/mic_adc
    chown system radio /sys/class/audio/codec/check_codec_id
    chown system audio /sys/class/dsm/max98505/dsm_log
    chown system audio /sys/class/dsm/max98506/dsm_log
    chown system audio /sys/class/dsm/maxdsm_cal/max
    chown system audio /sys/class/dsm/maxdsm_cal/min
    chown system audio /sys/class/dsm/maxdsm_cal/status
    chown system audio /sys/class/dsm/maxdsm_cal/duration
    chown system audio /sys/class/dsm/maxdsm_cal/temp
    chown system audio /sys/class/dsm/maxdsm_cal/rdc
    mkdir /data/firmware 0770 audioserver system
    mkdir /efs/maxim 0770 system audio
    chown system audio /efs/maxim/temp_cal
    chown system audio /efs/maxim/rdc_cal
    chmod 0660 /efs/maxim/temp_cal
    chmod 0660 /efs/maxim/rdc_cal
    chown audioserver system /data/firmware
    chown system system /sys/class/audio/earjack/water_detected
    chmod 0440 /sys/class/audio/earjack/water_detected

    # Permissions Camera
    mkdir /data/camera 0770 cameraserver system
    chown system radio /sys/class/camera/rear/rear_camfw
    chown system radio /sys/class/camera/rear/rear_camfw_full
    chown system radio /sys/class/camera/rear/rear_checkfw_user
    chown system radio /sys/class/camera/rear/rear_checkfw_factory
    chown system radio /sys/class/camera/rear/rear_sensor_standby
    chown system radio /sys/class/camera/rear/rear_camtype
    chown system radio /sys/class/camera/rear/rear_companionfw
    chown system radio /sys/class/camera/rear/rear_companionfw_full
    chown system radio /sys/class/camera/rear/rear_calcheck
    chown system radio /sys/class/camera/rear/isp_core
    chown system radio /sys/class/camera/rear/fw_update
    chown system radio /sys/class/camera/rear/companion_ic_check
    chown system radio /sys/class/camera/flash/rear_flash
    chown cameraserver system /sys/class/camera/flash/torch_flash
    chown cameraserver system /sys/class/camera/flash/rear_torch_flash
    chown system radio /sys/class/camera/front/front_camfw
    chown system radio /sys/class/camera/front/front_camfw_full
    chown system radio /sys/class/camera/front/front_checkfw_factory
    chown system radio /sys/class/camera/front/front_camtype
    chown system radio /sys/class/camera/ois/selftest
    chown system radio /sys/class/camera/ois/ois_power
    chown system radio /sys/class/camera/ois/ois_rawdata
    chown system radio /sys/class/camera/ois/oisfw
    chown system radio /sys/class/camera/ois/ois_diff
    chown system radio /sys/class/camera/ois/autotest

# SVC LED
    chown system system /sys/class/sec/led/led_r
    chown system system /sys/class/sec/led/led_g
    chown system system /sys/class/sec/led/led_b

    chown system system /sys/class/leds/led_r/brightness
    chown system system /sys/class/leds/led_g/brightness
    chown system system /sys/class/leds/led_b/brightness
    chown system system /sys/class/leds/led_r/delay_on
    chown system system /sys/class/leds/led_g/delay_on
    chown system system /sys/class/leds/led_b/delay_on
    chown system system /sys/class/leds/led_r/delay_off
    chown system system /sys/class/leds/led_g/delay_off
    chown system system /sys/class/leds/led_b/delay_off
    chown system system /sys/class/leds/led_r/blink
    chown system system /sys/class/leds/led_g/blink
    chown system system /sys/class/leds/led_b/blink

    chown system system /sys/class/sec/led/led_pattern
    chown system system /sys/class/sec/led/led_blink
    chown system system /sys/class/sec/led/led_br_lev
    chown system system /sys/class/sec/led/led_lowpower

# Permissions for CHARGING
    chown system radio /sys/class/power_supply/battery/batt_self_discharging_control
    chown system radio /sys/class/power_supply/battery/batt_inbat_wireless_cs100

#Private Mode
    mkdir /mnt/shell/privatemode 0700 system system
    mkdir /storage/Private 0000 system system
    mkdir /data/privatemode 0770 system system
    chown system system /data/privatemode
    restorecon /data/privatemode

on boot
    # override init.rc to keep plenty of large order chunks around
    # to improve allocation times
    # write /proc/sys/vm/min_free_kbytes 32768
    # write /proc/sys/vm/min_free_order_shift 1
    write /sys/module/selinux/parameters/selinux_fakemode 0
    setenforce 0
    write /sys/fs/selinux/enforce 0

# SSWAP
    write /proc/sys/vm/swappiness 190

    # Allow to access debugfs for system:system
    chmod 755 /sys/kernel/debug
    chown system system /sys/kernel/debug

    # Set up kernel tracing, but disable it by default
    chmod 0222 /sys/kernel/debug/tracing/trace_marker
    write /sys/kernel/debug/tracing/tracing_on 0

    # PMS DVFS
    chown system system /sys/power/cpuhotplug/enabled
    chown system system /sys/power/cpuhotplug/min_online_cpu
    chown system system /sys/power/cpuhotplug/max_online_cpu
    chmod 0664 /sys/power/cpuhotplug/enabled
    chmod 0664 /sys/power/cpuhotplug/min_online_cpu
    chmod 0664 /sys/power/cpuhotplug/max_online_cpu

    chown radio system /sys/devices/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/available_frequencies
    chmod 0664 /sys/devices/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/available_frequencies
    chown radio system /sys/devices/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/min_freq
    chmod 0664 /sys/devices/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/min_freq
    chown radio system /sys/devices/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/max_freq
    chmod 0664 /sys/devices/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/max_freq
    chown radio system /sys/devices/17000020.devfreq_int/devfreq/17000020.devfreq_int/available_frequencies
    chmod 0664 /sys/devices/17000020.devfreq_int/devfreq/17000020.devfreq_int/available_frequencies
    chown radio system /sys/devices/17000020.devfreq_int/devfreq/17000020.devfreq_int/min_freq
    chmod 0664 /sys/devices/17000020.devfreq_int/devfreq/17000020.devfreq_int/min_freq
    chown radio system /sys/devices/17000020.devfreq_int/devfreq/17000020.devfreq_int/max_freq
    chmod 0664 /sys/devices/17000020.devfreq_int/devfreq/17000020.devfreq_int/max_freq
    chown radio system /sys/devices/17000030.devfreq_disp/devfreq/17000030.devfreq_disp/available_frequencies
    chmod 0664 /sys/devices/17000030.devfreq_disp/devfreq/17000030.devfreq_disp/available_frequencies
    chown radio system /sys/devices/17000030.devfreq_disp/devfreq/17000030.devfreq_disp/min_freq
    chmod 0664 /sys/devices/17000030.devfreq_disp/devfreq/17000030.devfreq_disp/min_freq
    chown radio system /sys/devices/17000030.devfreq_disp/devfreq/17000030.devfreq_disp/max_freq
    chmod 0664 /sys/devices/17000030.devfreq_disp/devfreq/17000030.devfreq_disp/max_freq
    chown radio system /sys/devices/17000040.devfreq_cam/devfreq/17000040.devfreq_cam/available_frequencies
    chmod 0664 /sys/devices/17000040.devfreq_cam/devfreq/17000040.devfreq_cam/available_frequencies
    chown radio system /sys/devices/17000040.devfreq_cam/devfreq/17000040.devfreq_cam/min_freq
    chmod 0664 /sys/devices/17000040.devfreq_cam/devfreq/17000040.devfreq_cam/min_freq
    chown radio system /sys/devices/17000040.devfreq_cam/devfreq/17000040.devfreq_cam/max_freq
    chmod 0664 /sys/devices/17000040.devfreq_cam/devfreq/17000040.devfreq_cam/max_freq

    chown radio system /sys/devices/14ac0000.mali/dvfs_table
    chmod 0664 /sys/devices/14ac0000.mali/dvfs_table
    chown radio system /sys/devices/14ac0000.mali/dvfs_min_lock
    chmod 0664 /sys/devices/14ac0000.mali/dvfs_min_lock
    chown radio system /sys/devices/14ac0000.mali/dvfs_max_lock
    chmod 0664 /sys/devices/14ac0000.mali/dvfs_max_lock

    chown radio system /sys/devices/system/sec_os_ctrl/migrate_os
    chmod 664 /sys/devices/system/sec_os_ctrl/migrate_os

    chown radio system /sys/module/cpuidle/parameters/off
    chmod 0664 /sys/module/cpuidle/parameters/off

    chown system system /sys/module/sec_core/parameters/smpl_warn_count
    chmod 0660 /sys/module/sec_core/parameters/smpl_warn_count

    # Change permission for interactive governor
    # Cluster0 (Apollo)
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_slack
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_slack
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/boost
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/boost
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/boostpulse
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/input_boost
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/input_boost
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/boostpulse_duration
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/boostpulse_duration
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy

    # Assume HMP uses shared cpufreq policy for all LITTLE CPUs
    chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
    chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

    chown system system sys/devices/system/cpu/cpufreq/mp-cpufreq/cluster0_max_freq
    chmod 0660 sys/devices/system/cpu/cpufreq/mp-cpufreq/cluster0_max_freq
    chown system system sys/devices/system/cpu/cpufreq/mp-cpufreq/boot_low_freq
    chmod 0660 sys/devices/system/cpu/cpufreq/mp-cpufreq/boot_low_freq

	#MST HW Support
    setprop ro.mst.support 1

    # Cluster1 (Mongoose)
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_slack
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_slack
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/boost
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/boost
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/boostpulse
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/input_boost
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/input_boost
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/boostpulse_duration
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/boostpulse_duration
    chown system system /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy
    chmod 0660 /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy

    # MSP Core Status
    chown system system /sys/devices/system/cpu/cpu1/online
    chown system system /sys/devices/system/cpu/cpu2/online
    chown system system /sys/devices/system/cpu/cpu3/online
    chown system system /sys/devices/system/cpu/cpu4/online
    chown system system /sys/devices/system/cpu/cpu5/online
    chown system system /sys/devices/system/cpu/cpu6/online
    chown system system /sys/devices/system/cpu/cpu7/online

    # CPU Idle
    chown system system /sys/module/cpuidle_exynos64/parameters/enable_mask

    # S/W self discharging
    chown system system /sys/power/cpufreq_self_discharging
    chmod 0660 /sys/power/cpufreq_self_discharging

    # ASV
    chown system system /d/asv_summary

    #AP2CP PLL SHARE
    chown system system /sys/power/call_state
    chmod 660 /sys/power/call_state

# Switch Device
    chown system radio /sys/class/sec/switch/afc_disable

# Bluetooth
    chown bluetooth bluetooth /dev/ttySAC1
    chmod 0660 /dev/ttySAC1
    # permissions for bluetooth.
    setprop ro.bt.bdaddr_path "/efs/bluetooth/bt_addr"
    chown bluetooth bluetooth ro.bt.bdaddr_path
    chown radio bluetooth /efs/bluetooth/bt_addr
    chmod 0640 /efs/bluetooth/bt_addr
    chmod 0660 /sys/class/rfkill/rfkill0/state
    chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
    chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type

#for datarouter
    chown system system /dev/dun
    chown system system /dev/ttyGS0
    chown system system /dev/ttyGS1
    chown system system /dev/ttyGS2
    chown system system /dev/ttyGS3


# DRK permission
    mkdir /efs/prov 0770 radio system
    chown radio system /efs/prov_data
    chmod 0770 /efs/prov_data
    chown radio system /efs/prov_data/dev_root
    chmod 0770 /efs/prov_data/dev_root
    chown radio system /efs/prov_data/knox
    chmod 0770 /efs/prov_data/knox
    chown radio system /efs/prov_data/dev_root/dev_root.dat
    chmod 0640 /efs/prov_data/dev_root/dev_root.dat
    chown radio system /efs/prov/libdevkm.lock
    chmod 0660 /efs/prov/libdevkm.lock
    write /efs/prov/ffffffff00000000000000000000000c.tlbin 0
    chown radio system /efs/prov/ffffffff00000000000000000000000c.tlbin
    chmod 0660 /efs/prov/ffffffff00000000000000000000000c.tlbin

# CS socket
    mkdir /dev/socket/cs_socket 0770 system system

# MSP FactoryApp
	mkdir /efs/FactoryApp 0775 system system

# lcd a2-line
    copy /system/vendor/firmware/a2_line.dat /efs/FactoryApp/a2_line.dat
    chown system system /efs/FactoryApp/a2_line.dat
    chmod 0640 /efs/FactoryApp/a2_line.dat


# IPSec for VOLTE
    chown root system /dev/socket
    chmod 0775 /dev/socket

on fs
    mount_all /fstab.samsungexynos8890
    setprop ro.crypto.fuse_sdcard true

#For Absolute Persistence Partition
    mkdir /persdata 0755 system system
    mkdir /persdata/absolute 0750 system system

    wait /dev/block/platform/155a0000.ufs/by-name/PERSDATA
    mount ext4 /dev/block/platform/155a0000.ufs/by-name/PERSDATA /persdata/absolute nosuid nodev noatime noauto_da_alloc,discard,journal_async_commit,errors=panic

    chown system system /persdata
    chmod 0755 /persdata
    chown system system /persdata/absolute
    chmod 0750 /persdata/absolute

# Permissions for TouchScreen
    chown system radio /sys/class/sec/tsp/cmd
    chown system system /sys/class/sec/tsp/input/enabled

# Permissions for Touchkey
    chown system radio /sys/class/sec/sec_touchkey/brightness
    chown system radio /sys/class/sec/sec_touchkey/touchkey_firm_update
    chown system radio /sys/class/sec/sec_touchkey/touch_sensitivity
    chown system radio /sys/class/sec/sec_touchkey/glove_mode
    chown system radio /sys/class/sec/sec_touchkey/flip_mode
    chown system radio /sys/class/sec/sec_touchkey/keyboard_mode
    chown system system /sys/class/sec/sec_touchkey/input/enabled

# Permissions for gpio_keys
    chown radio system /sys/class/sec/sec_key/wakeup_keys
    write /sys/class/sec/sec_key/wakeup_keys 116,172

# Permissions for input_booster
    chown system radio /sys/class/input_booster/level
    chown system radio /sys/class/input_booster/head
    chown system radio /sys/class/input_booster/tail
    chmod 0664 /sys/class/input_booster/level
    chmod 0664 /sys/class/input_booster/head
    chmod 0664 /sys/class/input_booster/tail

# Permissions for ION
    chmod 0660 /sys/class/ion_cma/ion_video_ext/isolated
    chown system system /sys/class/ion_cma/ion_video_ext/isolated

# Permissions for backlight
    chmod 0660 /sys/class/backlight/panel/brightness
    chown system system /sys/class/backlight/panel/brightness
    chown system system /sys/class/backlight/panel/auto_brightness
    chown system system /sys/class/backlight/panel/auto_brightness_level
    chown system system /sys/class/backlight/panel/weakness_ccb

# Permissions for LCD HMT
    chown system system /sys/class/lcd/panel/hmt_on
    chown system system /sys/class/lcd/panel/hmt_bright
    chown system system /sys/class/mdnie/mdnie/hmt_color_temperature

# Permissions for LCD ALPM
    chown system system /sys/class/lcd/panel/alpm

# Permissions for LCD
    chown system radio /sys/class/lcd/panel/manufacture_code
    chown system radio /sys/class/lcd/panel/lcd_type
    chown system system /sys/class/lcd/panel/siop_enable
    chown system system /sys/class/lcd/panel/temperature
    chown system radio /sys/class/lcd/panel/mcd_mode
    chown system media_rw /sys/class/backlight/panel/weakness_hbm_comp
    chown system system /sys/class/lcd/panel/ldu_correction
    chown system system /sys/class/lcd/panel/lux
    chown system media_rw /sys/class/lcd/panel/adaptive_control
    chown system media_rw /sys/class/lcd/panel/resolution
    chown system system /sys/class/lcd/panel/SVC_OCTA

# Permissions for MDNIE
    chown system media_rw /sys/class/mdnie/mdnie/mode
    chown system media_rw /sys/class/mdnie/mdnie/scenario
    chown system system /sys/class/mdnie/mdnie/accessibility
    chown system system /sys/class/mdnie/mdnie/auto_brightness
    chown system system /sys/class/mdnie/mdnie/sensorRGB
    chown system system /sys/class/mdnie/mdnie/mdnie_ldu
    chown system system /sys/class/mdnie/mdnie/hdr
    chown system system /sys/class/mdnie/mdnie/night_mode
    chown system system /sys/class/mdnie/mdnie/whiteRGB

# Permissions for System LSI NFC
# NFC : Permissions for NFC
    chmod 0660 /dev/sec-nfc
# NFC : change owner
    chown nfc nfc /dev/sec-nfc

# Permissions for NXP NFC
# NFC : Permissions for NFC
    chmod 0660 /dev/pn547
# NFC : change owner
    chown nfc nfc /dev/pn547

# Permissions for NXP ESE
    chmod 0660 /dev/p61
    chown system system /dev/p61

# Permissions for S.LSI ESE
    chmod 0660 /dev/p3
    chown system system /dev/p3

# NFC : create data/nfc for nv storage
    mkdir /efs/sec_efs/nfc 0500 nfc nfc

# Fingerprint
    mkdir /dev/validity 0770 system system

# terminal mode
    chmod 0660 /sys/class/android_usb/android0/terminal_version
    chown system system /sys/class/android_usb/android0/terminal_version

# SENSORS
# Fingerprint_sensor
    chown system radio /sys/class/fingerprint/fingerprint/type_check
    chown system radio /sys/class/fingerprint/fingerprint/name
    chown system radio /sys/class/fingerprint/fingerprint/vendor

# Accelerometer_sensor
    chown system radio /sys/class/sensors/accelerometer_sensor/raw_data
    chown system radio /sys/class/sensors/accelerometer_sensor/calibration
    chown system radio /sys/class/sensors/accelerometer_sensor/reactive_alert
    chown system radio /sys/class/sensors/accelerometer_sensor/vendor
    chown system radio /sys/class/sensors/accelerometer_sensor/name
    chown system radio /sys/class/sensors/accelerometer_sensor/selftest
    chown system radio /sys/class/sensors/accelerometer_sensor/lowpassfilter

# Proximity_sensor
    chown system radio /sys/class/sensors/proximity_sensor/state
    chown system radio /sys/class/sensors/proximity_sensor/raw_data
    chown system radio /sys/class/sensors/proximity_sensor/prox_avg
    chown system radio /sys/class/sensors/proximity_sensor/prox_cal
    chown system radio /sys/class/sensors/proximity_sensor/vendor
    chown system radio /sys/class/sensors/proximity_sensor/name
    chown system radio /sys/class/sensors/proximity_sensor/thresh_high
    chown system radio /sys/class/sensors/proximity_sensor/thresh_low
    chown system radio /sys/class/sensors/proximity_sensor/barcode_emul_en
    chown system radio /sys/class/sensors/proximity_sensor/prox_offset_pass
    chown system radio /sys/class/sensors/proximity_sensor/prox_trim
    chown system radio /sys/class/sensors/proximity_sensor/prox_probe

# Light_sensor
    chown system radio /sys/class/sensors/light_sensor/lux
    chown system radio /sys/class/sensors/light_sensor/raw_data
    chown system radio /sys/class/sensors/light_sensor/vendor
    chown system radio /sys/class/sensors/light_sensor/name

# Gyro_sensor
    chown system radio /sys/class/sensors/gyro_sensor/power_on
    chown system radio /sys/class/sensors/gyro_sensor/power_off
    chown system radio /sys/class/sensors/gyro_sensor/temperature
    chown system radio /sys/class/sensors/gyro_sensor/selftest
    chown system radio /sys/class/sensors/gyro_sensor/selftest_dps
    chown system radio /sys/class/sensors/gyro_sensor/vendor
    chown system radio /sys/class/sensors/gyro_sensor/name

# Barometer_sensor
    chown system radio /sys/class/sensors/barometer_sensor/sea_level_pressure
    chown system radio /sys/class/sensors/barometer_sensor/vendor
    chown system radio /sys/class/sensors/barometer_sensor/name
    chown system radio /sys/class/sensors/barometer_sensor/calibration
    chown system radio /sys/class/sensors/barometer_sensor/temperature

# Magnetic_sensor
    chown system radio /sys/class/sensors/magnetic_sensor/raw_data
    chown system radio /sys/class/sensors/magnetic_sensor/vendor
    chown system radio /sys/class/sensors/magnetic_sensor/name

# HRM_sensor
    chown system radio /sys/class/sensors/hrm_sensor/name
    chown system radio /sys/class/sensors/hrm_sensor/vendor
    chown system radio /sys/class/sensors/hrm_sensor/led_current
    chown system radio /sys/class/sensors/hrm_sensor/led_current1
    chown system radio /sys/class/sensors/hrm_sensor/led_current2
    chown system radio /sys/class/sensors/hrm_sensor/led_current3
    chown system radio /sys/class/sensors/hrm_sensor/led_current4
    chown system radio /sys/class/sensors/hrm_sensor/hr_range
    chown system radio /sys/class/sensors/hrm_sensor/hr_range2
    chown system radio /sys/class/sensors/hrm_sensor/look_mode_ir
    chown system radio /sys/class/sensors/hrm_sensor/look_mode_red
    chown system radio /sys/class/sensors/hrm_sensor/eol_test
    chown system radio /sys/class/sensors/hrm_sensor/eol_test_result
    chown system radio /sys/class/sensors/hrm_sensor/eol_test_status
    chown system radio /sys/class/sensors/hrm_sensor/int_pin_check
    chown system radio /sys/class/sensors/hrm_sensor/lib_ver
    chown system radio /sys/class/sensors/hrm_sensor/regulator
    chown system radio /sys/class/sensors/hrm_sensor/part_type
    chown system radio /sys/class/sensors/hrm_sensor/device_id
    chown system radio /sys/class/sensors/hrm_sensor/hrm_flush
    chown system radio /sys/class/sensors/hrm_sensor/threshold
    chown system radio /sys/class/sensors/hrm_sensor/alc_enable
    chown system radio /sys/class/sensors/hrm_sensor/eol_lib_ver
    chown system radio /sys/class/sensors/hrm_sensor/elf_lib_ver
    chown system radio /sys/class/sensors/hrm_sensor/adpd_reg_read
    chown system radio /sys/class/sensors/hrm_sensor/adpd_reg_write
    chown system radio /sys/class/sensors/hrm_sensor/adpd_mode
    chown system radio /sys/class/sensors/hrm_sensor/adpd_configuration
    chown system radio /sys/class/sensors/hrm_sensor/adpd_stat
    chmod 0600 /dev/max_hrm
    chown system system /dev/max_hrm

# HRMLED_sensor
    chown system radio /sys/class/sensors/hrmled_sensor/name
    chown system radio /sys/class/sensors/hrmled_sensor/vendor
    chown system radio /sys/class/sensors/hrmled_sensor/hrmled_flush

# UV_sensor
    chown system radio /sys/class/sensors/uv_sensor/name
    chown system radio /sys/class/sensors/uv_sensor/vendor
    chown system radio /sys/class/sensors/uv_sensor/uv_lib_ver
    chown system radio /sys/class/sensors/uv_sensor/uv_sr_interval
    chown system radio /sys/class/sensors/uv_sensor/uv_eol_test
    chown system radio /sys/class/sensors/uv_sensor/uv_flush

# Grip_sensor
    chown system radio /sys/class/sensors/grip_sensor/name
    chown system radio /sys/class/sensors/grip_sensor/vendor
    chown system radio /sys/class/sensors/grip_sensor/raw_data
    chown system radio /sys/class/sensors/grip_sensor/threshold
    chown system radio /sys/class/sensors/grip_sensor/calibration
    chown system radio /sys/class/sensors/grip_sensor/onoff
    chown system radio /sys/class/sensors/grip_sensor/reset
    chown system radio /sys/class/sensors/grip_sensor/mode
    chown system radio /sys/class/sensors/grip_sensor/gain
    chown system radio /sys/class/sensors/grip_sensor/start
    chown system radio /sys/class/sensors/grip_sensor/normal_threshold
    chown system radio /sys/class/sensors/grip_sensor/gain_ch2
    chown system radio /sys/class/sensors/grip_sensor/raw_data_ch2
    chown system radio /sys/class/sensors/grip_sensor/diff_avg_ch2
    chown system radio /sys/class/sensors/grip_sensor/normal_threshold_ch2
    chown system radio /sys/class/sensors/grip_sensor/ch_state
    chown system radio /sys/class/sensors/grip_sensor/body_threshold
    chown system radio /sys/class/sensors/grip_sensor/grip_flush

# SensorHub
    chown system radio /sys/class/sensors/ssp_sensor/enable
    chown system radio /sys/class/sensors/ssp_sensor/mcu_rev
    chown system radio /sys/class/sensors/ssp_sensor/mcu_name
    chown system radio /sys/class/sensors/ssp_sensor/mcu_test
    chown system radio /sys/class/sensors/ssp_sensor/mcu_reset
    chown system radio /sys/class/sensors/ssp_sensor/mcu_update
    chown system radio /sys/class/sensors/ssp_sensor/mcu_sleep_test
    chown system radio /sys/class/sensors/ssp_sensor/ori_poll_delay

# Sensorhub IIO
    chown system radio /sys/class/sensors/ssp_sensor/accel_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/rot_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/game_rot_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/step_det_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/gyro_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/uncalib_gyro_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/mag_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/uncal_mag_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/light_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/pressure_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/tilt_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/pickup_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/prox_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/sig_motion_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/step_cnt_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/uncal_gyro_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/interrupt_gyro_poll_delay
    chown system radio /sys/class/sensors/ssp_sensor/ssp_flush
    chown system radio /sys/class/sensors/ssp_sensor/sensor_state

 # MOBEAM
    chown system radio /sys/class/sec/sec_barcode_emul/vendor
    chown system radio /sys/class/sec/sec_barcode_emul/name
    chown system radio /sys/class/sec/sec_barcode_emul/barcode_send
    chown system radio /sys/class/sec/sec_barcode_emul/barcode_led_status
    chown system radio /sys/class/sec/sec_barcode_emul/barcode_ver_check

# Meta event
    chown system radio /sys/class/sensors/sensor_dev/flush

# IRLED_sensor
    chown system radio /sys/class/sensors/irled_remote/name
    chown system radio /sys/class/sensors/irled_remote/vendor
    chown system radio /sys/class/sensors/irled_remote/irled_send
    chown system radio /sys/class/sensors/irled_remote/irled_send_result

# DATA_INJECTION
	chown system radio /sys/class/sensors/ssp_sensor/data_injection_enable

# Permissions for hall
    chown system radio /sys/class/sec/sec_key/hall_irq_ctrl

#ARGOSD network_throughput
    chown system system /dev/network_throughput

#Current meter node
    chown system system /sys/class/rtc/rtc0/device/adc_reg_0
    chown system system /sys/class/rtc/rtc0/device/adc_reg_1
    chown system system /sys/class/rtc/rtc0/device/adc_reg_2
    chown system system /sys/class/rtc/rtc0/device/adc_reg_3
    chown system system /sys/class/rtc/rtc0/device/adc_reg_4
    chown system system /sys/class/rtc/rtc0/device/adc_reg_5
    chown system system /sys/class/rtc/rtc0/device/adc_reg_6
    chown system system /sys/class/rtc/rtc0/device/adc_reg_7
    chown system system /sys/class/rtc/rtc0/device/adc_ctrl1

#~ # Copy DRM Key
    #~ copy /system/app/wv.keys /factory/wv.keys

#~ # Permission for DRM Key
    #~ chmod 0644 /factory/wv.keys

# umount service
service umount_service /system/bin/umount -D /preload
    disabled
    oneshot

# Support Preload install apks
on property:persist.sys.storage_preload=1
    mount ext4 /dev/block/platform/155a0000.ufs/by-name/HIDDEN /preload nosuid nodev ro barrier=1
    setprop storage.preload.complete 1

on property:persist.sys.storage_preload=0
    start umount_service

# Set watchdog timer to 30 seconds and pet it every 10 seconds to get a 20 second margin
service watchdogd /sbin/watchdogd 10 20
    class core
    seclabel u:r:watchdogd:s0

# on userdebug and eng builds, enable kgdb on the serial console
on property:ro.debuggable=1
    write /sys/module/kgdboc/parameters/kgdboc ttyFIQ1
    write /sys/module/fiq_debugger/parameters/kgdb_enable 1

on property:ro.bootmode=charger
    wait /dev/block/platform/155a0000.ufs/by-name/EFS
    mount ext4 /dev/block/platform/155a0000.ufs/by-name/EFS /efs nosuid nodev noatime noauto_da_alloc,discard,journal_async_commit,errors=panic

on charger
# Set cpu governor to powersave while in charging mode
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor powersave
    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor powersave
    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor powersave
    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor powersave

service charger /charger
    class charger
    critical
    seclabel u:r:charger:s0

# sem_daemon permission
    chown system system /efs/sec_efs/ssp_data
    chmod 0644 /efs/sec_efs/ssp_data

# sem_daemon
service sem_daemon /system/bin/sem_daemon
    class core
    user system
    group system nfc
    disabled

on property:sys.boot_completed=1
    setprop security.semdaemonfinish 0
    start sem_daemon

on property:security.semdaemonfinish=1
    stop sem_daemon

# Secure Storage startup
service secure_storage /system/bin/secure_storage_daemon
    class core
    user system
    group system
    disabled

on property:ro.securestorage.support=true
    mkdir /dev/.secure_storage
    chmod 0711 /dev/.secure_storage
    chown system system /dev/.secure_storage
    start secure_storage

# redsocks
service redsocks /system/bin/redsocks -c /data/mptcp/redsocks.conf
    class main
    user system
    group system net_raw net_admin
    disabled

# Sensorhub service
service sensorhubservice /system/bin/sensorhubservice
    class main
    user system
    group input

service cameraserver /system/bin/cameraserver
    class main
    user cameraserver
    group media_rw audio camera drmrpc inet shell sdcard_r system
    ioprio rt 4
    writepid /dev/cpuset/foreground/tasks
